package com.hqsj.controller;

import com.github.sd4324530.fastweixin.api.response.GetMaterialListResponse;
import com.github.sd4324530.fastweixin.message.TextMsg;
import com.hqsj.config.BeanFactory;
import com.hqsj.service.BeanService;
import com.hqsj.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by huangying on 2017/4/13.
 */
@RestController
@RequestMapping("test")
public class TestController {

//    @Autowired
//    private BeanService beanService;

    @Autowired
    private BeanFactory beanFactory;

    @Autowired
    private MaterialService materialService;

    @RequestMapping("test")
    public GetMaterialListResponse test() {
        return materialService.test();
    }

    @RequestMapping("bean")
    public String getBean(){
        BeanService beanService = beanFactory.beanService();
        beanService.print();
        return "success";
    }

    @RequestMapping("config")
    public String addBean(@RequestParam("name") String name){
        beanFactory.createBean(name);
        beanFactory.updateWeixinConfig("wxb317540508530064", "71af1380bc9bef4b02ec1ccbda9179cd", "yunyikaoyan");
        return "success";
    }

    @RequestMapping("send")
    public String sendMsg(@RequestParam("message") String message){
        beanFactory.customAPI().sendCustomMessage("oy2qbv3OxU3SgdGr_1Sf-AoLvk80", new TextMsg(message));
        return "success";
    }
}
